﻿using MC2Development.DevWebServer.Interfaces;

namespace MC2Development.DevWebServer
{
    /// <summary>
    /// Default authenticator
    /// </summary>
    internal class Authenticator : IAuthenticator
    {
        /// <summary>
        /// Authenticates the request
        /// </summary>
        /// <param name="suppliedCredentials">The credentials supplied with the request</param>
        /// <param name="expectedCredentials">The credentials to authenticate against</param>
        /// <returns>A boolean value indicating if authentication was successful</returns>
        public bool AuthenticateUser(Credentials suppliedCredentials, Credentials expectedCredentials)
        {
            using (new Tracer())
            {
                if (suppliedCredentials != null && expectedCredentials != null)
                {
                    return (suppliedCredentials.Username == expectedCredentials.Username
                                    && suppliedCredentials.Password == expectedCredentials.Password);
                }
                else
                {
                    return false;
                }
            }
        }
    }
}
